<template>
  <div class="balance-tx">
    <!-- TODO 小程序文字滚动 -->
    <text-marquee v-if="draw_alert" :marqueeText="draw_alert"></text-marquee>
    <!-- <div class="cashnote" v-if="draw_alert">
      <div class="cashtext">
        <p>温馨提示：{{draw_alert}}</p>
      </div>
    </div> -->
    <div class="balance-contanier">
      <ul class="balance-content clearfix">
        <li>
          <div class="item-balance">
            <p>
              余额
              <strong class="fontGilroy">
                <i>&yen;</i>
                {{userInfo.amount}}
              </strong>
            </p>
          </div>
        </li>
        <li>
          <div class="blocked">
            <p>
              冻结余额
              <strong class="fontGilroy">
                <i>&yen;</i>
                {{userInfo.frozen_amount}}
              </strong>
            </p>
          </div>
        </li>
      </ul>
      <div class="getcash-btn" :class="draw_alert?'mgt0':'mgt65'">
        <span class="cash-apply" v-if="!istl&&!is_weibei_dz" @click="verification">我要提现</span>
        <!-- <i id="disabled-click"></i> -->
        <span
          v-if="userInfo.company_prove"
          class="cash-apply"
          @click="showMaterial"
        >材料证明</span>
        <span class="cash-apply" v-if="istl" @click="clickTurnBalaceTlClick">转到通联余额</span>
        <span class="cash-apply" v-if="is_weibei_dz" @click="transferWeibeiClick">转到现金</span>
      </div>
      <!-- </div> -->
      
    </div>
    <!--  汇付分账 start  -->
    <div class="balance-contanier" v-if="adapay_info && adapay_info.adapay_switch">
      <p class="tl_title">汇付本金</p>
      <ul class="balance-content clearfix balance-content-tl">
        <li>
          <div class="item-balance">
            <p>
              已到账
              <strong class="fontGilroy">
                <i>{{is_crossBorderDz? mSymbol.name:'¥'}}</i>
                {{adapay_info.user_account}}
              </strong>
            </p>
          </div>
        </li>
        <li>
          <div class="item-balance">
            <p>
              不可提现
              <strong class="fontGilroy">
                <i>{{is_crossBorderDz? mSymbol.name:'¥'}}</i>
                {{adapay_info.user_wait_account}}
              </strong>
            </p>
          </div>
        </li>
      </ul>
      <div class="getcash-btn" :class="draw_alert?'mgt0':'mgt65'">
        <span class="cash-apply" @click="hfAdapay">我要提现</span>

      </div>
      <!-- </div> -->

    </div>
    <!-- 汇付分账 end -->
    <!--  通联余额  -->
    <div v-if="istl" class="balance-contanier">
      <p class="tl_title">通联余额</p>
      <ul class="balance-content clearfix balance-content-tl">
        <li>
          <div class="item-balance">
            <p>
              个人
              <strong class="fontGilroy">
                <i>{{is_crossBorderDz? mSymbol.name:'¥'}}</i>
                {{cashPopData.tlfz_balance.all_amount}}
              </strong>
            </p>
          </div>
        </li>
        <li>
          <div class="item-balance">
            <p>
              企业
              <strong class="fontGilroy">
                <i>{{is_crossBorderDz? mSymbol.name:'¥'}}</i>
                {{cashPopData.company_tlfz_balance.all_amount}}
              </strong>
            </p>
          </div>
        </li>
      </ul>
      <div class="getcash-btn" :class="draw_alert?'mgt0':'mgt65'">
        <span class="cash-apply" @click="verificationTl">我要提现</span>
      </div>
      <!-- </div> -->

    </div>
    
    <div class="cash-detail" :class="is_balance_draw != 1?'mgt65':''">
      <div class="tab-nav">
        <span v-if="is_wxpay_profit_sharing != 0" :class="type==1?'show':''" @click="clickItem(1)">
          分账明细
          <i></i>
        </span>
        <span :class="type==2?'show':''" @click="clickItem(2)">
          提现明细
          <i></i>
        </span>
        <span :class="type==3?'show':''" @click="clickItem(3)">
          余额变动记录
          <i></i>
        </span>
      </div>
      <!-- <div class="tab-nav" v-else>
        <span class="show">
          余额变动记录
          <i></i>
        </span>
      </div>-->
      <div class="detail-item">
        <detail-log ref="log1" v-show="type==1" @cancelTx="cancel" :listPage="listPage" @changeListPage="changeListPage"></detail-log>
        <tx-log ref="log2" v-show="type==2" @cancelTx="cancel" :listPage="listPage" @changeListPage="changeListPage"></tx-log>
        <balance-log ref="log3" v-show="type==3" :listPage="listPage" @changeListPage="changeListPage"></balance-log>
      </div>
    </div>
    <van-popup v-model="showCashPop" position="top" :style="{ height: '100%' }">
      <tx-pop @closePop="closeCashPop" :dzData="dzData" :cashPopData="cashPopData"></tx-pop>
    </van-popup>
    <van-popup v-model="showCashPopTl"
               position="top"
               :style="{ height: '100%' }">
      <txTlPop @closePop="closeTlCashPop"
               v-if="showCashPopTl"
               :dzData="dzData"
              :isTelCode="isTelCode"
               :cashPopData="cashPopData"></txTlPop>
    </van-popup>
    <van-popup v-model="showMaterialPop">
      <!-- <div class="diy_active_box_shade"></div>
      <input type="hidden" name="show_hide" id="show_hide" value="{$pay_gift.activity_type}" />-->
      <div class="diy_active_box">
        <!-- <p class="box_del">&times;</p> -->
        <div class="active_content">
          <img :src="userInfo.company_prove" alt />
        </div>
      </div>
      <!-- <tx-pop @closePop="closeCashPop" :dzData="dzData" :cashPopData="cashPopData"></tx-pop> -->
    </van-popup>
    <!-- 提现类型选择 -->
    <div class="withdrawalTypeBox_wrapper" v-show="withdrawalTypeShow">
      <div class="withdrawalTypeBox_block">
        <div class="block_img" @click="withdrawalTypeShow = false">
          <img src="https://img.wifenxiao.com/h5-wfx/images/user/icon_del.png" alt="">
        </div>
        <h6>提现类型</h6>
        <div class="block_selmain">
          <div class="block_selmain_item" @click="clickWithdrawalType(1)" :class="withdrawalType == 1 ? 'sel': ''">
            <i class="icon personal"></i>
            <p class="withdrawal_txt">
              <span class="check"></span>
              <span>个人提现</span>
            </p>
          </div>
          <div class="block_selmain_item" @click="clickWithdrawalType(2)"  v-if="cashPopData.is_open_enterprise && cashPopData.is_open_enterprise == 1" :class="withdrawalType == 2 ? 'sel': ''">
            <i class="icon enterprise"></i>
            <p class="withdrawal_txt">
              <span class="check"></span>
              <span>企业提现</span>
            </p>
          </div>
        </div>
        <div class="block_btn">
          <button class="block_btn_next" @click="clickNext()">下一步</button>
        </div>
      </div>
    </div>
    <!-- 汇付 start -->
    <!-- 汇付提现 -->
    <van-popup v-model="showCashPopHf" position="bottom" :style="{ height: '100%' }">
      <txHfPop @closePop="closeCashPop"
              @adapayStep="adapayStep"
              :cashPop="cashPopData"
              supplierWithdraw="1"
              :cashPopData="adapay_info"></txHfPop>
    </van-popup>
    <!-- 汇付开户 -->
    <van-popup v-model="showHfAuthentication" position="bottom" :style="{ height: '100%', background: '#f7f7f7' }">
      <hf-authentication @close="closeHfAuthentication" :hfActive="hfActive" :hfType="hfType" />
    </van-popup>
    <!-- 汇付 end -->
    <!-- 余额转通联余额弹窗 start -->
    <van-dialog
        v-model="showBalanceTurnBalanceTl"
        title="转到通联余额"
        show-cancel-button
        confirm-button-text="确定"
        class="common-confirm"
        :before-close="balanceTurnBalanceTlClick"
    >
      <div class="donation-box">
        <div class="con-box">
          <div class="input-box clearfix zhuan-box">
            <input type="number" name="point" placeholder="请输入金额" v-model="balanceTurnBalanceMoneyTl"/>
          </div>
        </div>
      </div>
    </van-dialog>
    <!-- 余额转通联余额弹窗 end -->
    <!-- 余额转微呗弹窗 start -->
    <van-dialog
      v-model="showBalanceTurnWeibei"
      title="转到现金"
      show-cancel-button
      confirm-button-text="确定"
      class="common-confirm"
      :before-close="showBalanceTurnWeibeiClick"
    >
      <div class="donation-box">
        <div class="con-box">
          <div class="input-box clearfix zhuan-box">
            <input type="number" name="point" placeholder="请输入金额" v-model="balanceTurnBalanceMoneyWeibei"/>
          </div>
        </div>
      </div>
    </van-dialog>
    <!-- 余额转微呗弹窗 end -->
  </div>
</template>

<script>
import Vue from 'vue'
import { getSupplierWithdraw } from '@/api/user/gys/gysApi'
import { getEnterpriseStatus, signContract, setGysBalanceTurnBalanceTl } from '@/api/user/member/memberApi'
// import { getMQCloud } from '@/api/dz/dzApi'
import txLog from './txLog/index'
import balanceLog from './balanceLog/index'
import detailLog from './detailLog/index'
import txPop from '@/views/user/components/txPop/index'
import textMarquee from '@/components/textMarquee' // 文字滚动
import txTlPop from '@/views/user/components/txTlPop/index'
import { weiBeiTransferAccount } from '@/api/dz/weibei'
import hfAuthentication from '@/views/user/fxs/myCommission/components/hfAuthentication'
import txHfPop from '@/views/user/fxs/myCommission/components/txHfPop'
export default Vue.extend({
  name: 'index',
  components: {
    detailLog,
    txLog,
    balanceLog,
    txPop,
    textMarquee,
    txTlPop,
    txHfPop,
    hfAuthentication
  },
  data() {
    return {
      type: 1, // 1为分账明细、2为提现明细、3为余额变动记录
      draw_alert: '',
      is_balance_draw: '', // 是否开启余额提现
      userInfo: {
        balance: '',
        frozen_balance: '',
        company_prove: ''
      },
      showMaterialPop: false, // 证明材料弹框
      is_wxpay_profit_sharing: '0',
      canClick: true,
      showCashPop: false,
      in_time: null, // 设置提现时间
      show_time_tip: null, // 提现时间提示
      is_draw_int: null, // 提现方式   整额   全额
      // remaining_commission: null,
      withdraw_multiple: null,
      withdraw_start_amount: null,
      code: null,
      txLog: [],
      balanceLog: [],
      isTelCode: false,
      page: 0,
      cashPopData: {
        is_balance: false, // 弹框判断是余额提现
        is_commission: false, // 弹框判断是佣金提现
        is_supplierWithdraw: true, // 弹框判断是供应商收入
        withdraw_type: [],
        draw_alert: '',
        bankList: null, // 银行列表
        user_behavior_jd: null, // 银行
        user_behavior_wechat: null, // 微信
        user_behavior_alipay: null, // 支付宝
        is_id_card: null,
        commssion_to_balance_rate: '',
        withdraw_proportion: '',
        is_qz: null,
        is_draw_int: null, // 提现方式   整额   全额
        withdraw_percentage: '',
        max_tx_money: null,
        min_tx_money: null,
        withdraw_apply_agreement: null,
        need_withdraw_apply_agreement: null,
        remaining_commission: null,
        withdraw_start_amount: null,
        withdraw_multiple: null,
        must_pay_password: null,
        popup_show: null,
        code: null,
        is_open_enterprise: null, // 是否开启企业提现
        withdraw_need_phone: null, // 是否填写手机号
        tlfz_is_opened: 0, // 是否开通通联
        member_info: {}, // 通联账号信息
        tlfz_balance: {},
        sign_contract_url: '' // 通联分账电子签约链接
      },
      dzData: {
        // 云账户
        is_mq_cloud: false,
        cloud_pay_now_type: [],
        cloud_type: null,
        cloud_default_1: null,
        cloud_default_2: null,
        cloud_default_3: null,
        // 薇曼
        is_wm_dz: false
      },
      // 企业提现
      withdrawalTypeShow: false, // 提现类型选择弹窗
      withdrawalType: 1, // 提现类型
      istl: 0,
      showCashPopTl: false,
      tlInfoObj: {},
      showBalanceTurnBalanceTl: false,
      balanceTurnBalanceMoneyTl: '',
            // 定制  转到微呗 satrt
      is_weibei_dz: false,
      showBalanceTurnWeibei: false,
      balanceTurnBalanceMoneyWeibei: '',
      // 定制  转到微呗 end
      listPage: 0,
      adapay_info: {}, // 汇付分账
      hfActive: 0, // 汇付分账步骤
      hfType: '1', // 汇付分账步骤类型
      showCashPopHf: false, // 汇付提现
      showHfAuthentication: false
    }
  },
  computed: {
    remaining_commission() {
      return parseFloat(this.userInfo.amount) || 0
    }
  },
  methods: {
    closeHfAuthentication(val) {
      this.showHfAuthentication = false
      document.title = this.titleDoc
      this.init()
    },
    adapayStep(data) {
      this.closeCashPop()
      this.hfAdapay()
    },
    // 汇付分账 我要提现
    hfAdapay() {
      if (this.adapay_info.adapay_company_apply_status == 0) {
        this.$Error(this.adapay_info.adapay_fail)
      } else if (this.adapay_info.adapay_company_apply_status == 2) {
        this.showHfAuthentication = true
        this.hfActive = 5
        document.title = '提现开户'
      } else {
        if (this.adapay_info.step == 0) {
          if (this.adapay_info.adapay_company_apply_status == 2) {
            this.$Error(this.adapay_info.adapay_fail)
          }
          this.showHfAuthentication = true
          this.hfActive = 0
          document.title = '提现开户'
        } else if (this.adapay_info.step == 1) {
          this.hfActive = 1
          this.hfType = 1
          this.showHfAuthentication = true
          document.title = '提现开户'
        } else {
          this.amount = null
          if (Number(this.adapay_info.user_account) > 0) {
            this.showCashPopHf = true
          } else {
            this.$Error('佣金为0元，不可提现')
          }
        }
      }
    },
    clickTurnBalaceTlClick() {
      this.showBalanceTurnBalanceTl = true
    },
    balanceTurnBalanceTlClick(action, done) {
      if (action == 'confirm') {
        if (this.userInfo.amount <= 0) {
          this.$Error('您的金额为0，不能转到通联余额')
          done(false)
          return false
        }
        if (!this.balanceTurnBalanceMoneyTl) {
          this.$Error('金额不能为空')
          done(false)
          return false
        } else {
          this.$loadingWrap.show()
          const sendData = {
            amount: this.balanceTurnBalanceMoneyTl
          }
          setGysBalanceTurnBalanceTl(sendData).then(res => {
            this.$loadingWrap.close()
            if (res.status == 1) {
              this.$Error('操作成功')
              this.balanceTurnBalanceMoneyTl = ''
              done()
              this.init()
            } else {
              this.$Error(res.msg)
            }
          })
        }
      } else {
        this.balanceTurnBalanceMoneyTl = ''
        done()
      }
    },
    init() {
      this.$loadingWrap.show()
      setTimeout(() => {
        this.$loadingWrap.close()
      }, 50000)
      getSupplierWithdraw().then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          const resData = res.data
          this.draw_alert = this.cashPopData.draw_alert = resData.draw_alert
          this.is_balance_draw = resData.is_balance_draw
          this.userInfo = resData.info
          this.is_wxpay_profit_sharing = resData.is_wxpay_profit_sharing
          // this.balanceLog = resData.balance_change
          this.in_time = resData.in_time
          this.show_time_tip = resData.specify_time
          this.is_draw_int = resData.is_draw_int
          // this.code = resData.code
          // // this.remaining_commission = this.cashPopData.remaining_commission =
          // //   resData.remaining_commission
          this.withdraw_multiple = resData.withdraw_multiple || 0
          this.withdraw_start_amount = resData.withdraw_start_amount || 0
          this.commission_name = resData.commission_name

          // 定制 转到微呗
          this.is_weibei_dz = resData.is_weibei_dz || 0
          // 汇付分账
          this.adapay_info = resData.adapay_info
           // 通联分账
          this.cashPopData.tlfz_is_opened = res.data.tlfz_is_opened || 0
          this.cashPopData.tlfz_balance = res.data.tlfz_balance
          this.cashPopData.member_info = res.data.member_info
          this.cashPopData.company_member_info = res.data.company_member_info || {}
          this.cashPopData.last_withdraw_info = res.data.last_withdraw_info
          this.sign_contract_url = res.data.sign_contract_url
          // 通联提现是否需要审核
          this.isTelCode = res.data.is_tl_enterprise_audit || 0

          this.cashPopData.company_tlfz_balance = res.data.company_tlfz_balance || { all_amount: 0 }
          this.cashPopData.company_tlfz_need_register = res.data.company_tlfz_need_register

          if (this.cashPopData.tlfz_is_opened) {
            this.istl = true
            this.cashPopData.company_tlfz_need_bind_phone = res.data.company_tlfz_need_bind_phone
            // this.tlObj = {}
            this.tlInfoObj.is_show_tl_balance = resData.is_show_tl_balance || 0
            this.tlInfoObj.txType = 1
            this.tlInfoObj.tlfz_is_opened = 1
            this.tlInfoObj.member_info = resData.member_info
            //  通联账余额
            this.tlInfoObj.tl_balance = resData.tlfz_balance.all_amount || '0.00'
            // 通联账户余额提现是否需要 签署
            this.tlInfoObj.tlfz_have_person_signed = resData.member_info.tlfz_have_person_signed || 0
          } else {
            this.istl = false
          }

          // 提现弹框
          this.cashPopData.withdraw_type = resData.withdraw_type
          this.cashPopData.bankList = resData.bank_list
          this.cashPopData.user_behavior_jd = resData.user_behavior_jd
          this.cashPopData.user_behavior_wechat = resData.user_behavior_wechat
          this.cashPopData.user_behavior_alipay = resData.user_behavior_alipay
          this.cashPopData.is_id_card = resData.is_id_card
          this.cashPopData.id_card_front_back = resData.id_card_front_back
          this.cashPopData.jzb_is_opened = resData.jzb_is_opened
          this.cashPopData.jzb_bank = res.data.jzb_bank
          // this.cashPopData.commssion_to_balance_rate =
          //   resData.commssion_to_balance_rate
          this.cashPopData.withdraw_proportion = resData.withdraw_proportion
          this.cashPopData.is_draw_int = resData.is_draw_int
          this.cashPopData.withdraw_percentage = resData.withdraw_percentage
          this.cashPopData.max_tx_money = resData.max_tx_money
          this.cashPopData.min_tx_money = resData.min_tx_money
          this.cashPopData.is_qz = resData.is_qz
          this.cashPopData.withdraw_apply_agreement =
            resData.withdraw_apply_agreement
          this.cashPopData.need_withdraw_apply_agreement =
            resData.need_withdraw_apply_agreement
          this.cashPopData.remaining_commission = this.remaining_commission
          this.cashPopData.withdraw_multiple = this.withdraw_multiple
          this.cashPopData.withdraw_start_amount = this.withdraw_start_amount
          this.cashPopData.must_pay_password = resData.must_pay_password
          this.cashPopData.popup_show = resData.popup_show
          this.cashPopData.code = resData.code
          // 是否开启企业提现
          this.cashPopData.is_open_enterprise = resData.is_open_enterprise
          if (this.istl) {
            // 通联放开企业提现
            this.cashPopData.is_open_enterprise = 1
          }
          // 是否填写手机号
          this.cashPopData.withdraw_need_phone = resData.withdraw_need_phone
          if (resData.is_wxpay_profit_sharing == 0) this.type = 2
        } else {
          this.$Error(res.msg)
        }
      })
    },
    // 切换提现明细和余额变动记录
    clickItem(i) {
      if (i != this.type) {
        this.type = i
      }
    },
    verification() {
      this.cashPopData.tlfz_is_opened = 0
      // 判断是否开启企业提现
      if (this.cashPopData.is_open_enterprise == 1) {
        this.withdrawalTypeShow = true
      } else {
        this.personalWithdrawal()
      }
    },
    // 通联余额提现
    verificationTl() {
      this.cashPopData.tlfz_is_opened = 1
      this.withdrawalTypeShow = true
    },
    // 提现类型选择
    clickWithdrawalType(type) {
      this.withdrawalType = type
      this.tlInfoObj.txType = type
    },
    // 下一步
    // 根据状态判断跳转链接
    jumpPath(url, data) {
      this.$JumpPath(this, url, data)
    },
    jumpName(name, data) {
      this.$JumpName(this, name, data)
    },
    changeListPage(data) {
      this.listPage = data
    },
    clickNext() {
      // console.log('withdrawalType', this.withdrawalType)

      if (this.istl) {
        this.checkTlfzRegister()
        return false
      }
      if (this.withdrawalType == 1) {
        this.personalWithdrawal()
      } else if (this.withdrawalType == 2) {
        this.$loadingWrap.show()
        setTimeout(() => {
          this.$loadingWrap.close()
        }, 10000)
        getEnterpriseStatus().then(res => {
          if (res.status == 1) {
            if (res.data == 0) {
              this.jumpPath('certification', '')
            } else if (res.data == 1) {
              this.jumpPath('certification-reviewing', '')
            } else if (res.data == 2) {
              const data = {
                withdrawType: 'supplierWithdraw',
                code: this.cashPopData.code
              }
              this.jumpPath('certification-review-success', data)
            } else if (res.data == 3) {
              const data = {
                withdrawType: 'supplierWithdraw',
                code: this.cashPopData.code
              }
              this.jumpPath('enterpriseTx-applyCash', data)
            } else if (res.data == 4) {
              this.jumpPath('certification-review-fail', '')
            }
          } else {
            this.$Error(res.msg)
          }
        })
      }
    },
    // 个人提现
    personalWithdrawal() {
      // 设置提现时间判断
      if (this.in_time == 0) {
        this.$Error(this.show_time_tip)
        return false
      }
      // 余额
      let minWithdraw = 0
      if (this.is_draw_int == 1) {
        minWithdraw = this.withdraw_multiple
      } else {
        minWithdraw = this.withdraw_start_amount
      }

      // 通联分账提现
      if (this.remaining_commission < +minWithdraw) {
        this.$Error(
          `您账户的${this.commission_name}余额不足${minWithdraw}元，不能申请提现！`
        )
      } else {
        this.showCash()
      }
    },
    personalWithdrawalTl(key) {
      // 设置提现时间判断
      if (this.in_time == 0) {
        this.$Error(this.show_time_tip)
        return false
      }
      // 余额
      let minWithdraw = 0
      if (this.is_draw_int == 1) {
        minWithdraw = this.withdraw_multiple
      } else {
        minWithdraw = this.withdraw_start_amount
      }
      let all_amount = this.cashPopData.tlfz_balance.all_amount
      if (key == 2) {
        all_amount = this.cashPopData.company_tlfz_balance.all_amount
      }
      if (all_amount - minWithdraw >= 0) {
        this.cashPopData.tlObj = this.tlInfoObj
        this.cashPopData.is_supplierWithdraw = true
        // this.showCash()
        this.showCashPopTl = true
      } else {
        this.$Error(
            `您账户的通联可提现${this.commission_name}不足${minWithdraw}${this.is_crossBorderDz ? this.mSymbol.name : '元'}，不能申请提现！`
        )
      }
    },
    checkTlfzRegister() {
      // console.log(this.withdrawalType, this.cashPopData.member_info.tlfz_have_person_signed, this.cashPopData.member_info.contract_status)
      //  个人提现
      if (this.withdrawalType == 1) {
        this.tlInfoObj.txType = 1
        this.cashPopData.tlObj = this.tlInfoObj
        // 实名认证或绑定手机号未成功
        if (this.cashPopData.member_info.tlfz_have_person_signed != 1) {
          this.jumpName('tlQualification')
          return false
        } else if (this.cashPopData.member_info.contract_status != 1) {
          // 通联电子签约未签约,跳去通联签约
          signContract({ member_type: 3 }).then(res => {
            if (res.status == 1) {
              const tlfzUrl = res.data.jump_url
                // 跳转通商云平台账户的小程序
                wx.navigateToMiniProgram({
                  appId: 'wxc46c6d2eed27ca0a',//通商云平台账户小程序appId
                  path: 'pages/merchantAddress/merchantAddress',
                  extraData: {
                    targetUrl: tlfzUrl//商户拼接的请求报文
                  },
                  success(res) {
                    // 打开成功
                    // console.log(res)
                  },
                  fail(error) {
                    this.$Error('签约跳转失败')
                  }
                })
            } else {
              this.$Error(res.msg)
            }
          })
          return false
        } else {
          this.personalWithdrawalTl(1)
        }
      } else if (this.withdrawalType == 2) {
        this.tlInfoObj.txType = 2
        this.cashPopData.tlObj = this.tlInfoObj
        const checkResult = this.cashPopData.company_member_info.check_result
        if (this.cashPopData.company_tlfz_need_register == 1) { // 企业提现
          this.jumpName('tlQualiConmpany')
          return false
        } else if (checkResult != 2) {
          // 认证结果：0认证中，1待审核，2成功，3失败
          if (checkResult == 0 || checkResult == 1) {
            this.$Error('审核中，请稍后重试')
            return false
          } else if (checkResult == 3) {
            this.$Error('审核失败，请重新签署')
            this.jumpName('tlQualiConmpany')
            return false
          }
        } else if (this.cashPopData.company_tlfz_need_bind_phone == 1) { // 绑定手机号
          this.jumpName('tlQualiBindPhone')
          return false
        } else if (this.cashPopData.company_member_info.ocr_idcard_comparison_result != 1 || this.cashPopData.company_member_info.ocr_regnum_comparison_result != 1) { // 影印件采集
          this.jumpName('tlQualiUpload', { idCard: this.cashPopData.company_member_info.ocr_idcard_comparison_result, comUp: this.cashPopData.company_member_info.ocr_regnum_comparison_result })
          return false
        } else if (this.cashPopData.company_member_info.contract_status != 1) {
          // 通联电子签约未签约,跳去通联签约
          signContract({ member_type: 2 }).then(res => {
            if (res.status == 1) {
              const tlfzUrl = res.data.jump_url
              window.location.href = tlfzUrl
            } else {
              this.$Error(res.msg)
            }
          })
          return false
        } else {
          this.personalWithdrawalTl(2)
        }
      }
    },
    // 提现弹框
    showCash() {
      if (this.canClick) {
        this.canClick = false
        setTimeout(() => {
          this.canClick = true
        }, 10000)
        this.showCashPop = true
      } else {
        this.$Error('两次操作,请间隔10秒')
      }
    },
    // 关闭提现弹框
    closeCashPop() {
      this.showCashPop = false
      this.showCashPopTl = false
      this.showCashPopHf = false // 汇付
    },
    closeTlCashPop(data) {
      this.showCashPop = false
      this.showCashPopTl = false
      this.withdrawalTypeShow = false
      // console.log('data', data)
      if (data == 1) {
        // console.log('sadadasdadasdas')
        this.init()
        this.listPage = 1
      }
    },
    // 展示证明材料
    showMaterial() {
      this.showMaterialPop = true
    },
    // 取消提现
    cancel(id) {
      this.$loadingWrap.show()
      setTimeout(() => {
        this.$loadingWrap.close()
      }, 10000)
      // const data = {
      //   id,
      //   code: this.code
      // }
      // cancelTx(data).then(res => {
      //   this.$loadingWrap.close()
      //   if (res.status == 1) {
      //     if (res.data.status == 1) {
      //       this.$Error('操作成功')
      //       setTimeout(() => {
      //         window.location.reload()
      //       }, 1000)
      //     } else {
      //       this.$Error(res.data.msg)
      //     }
      //   } else {
      //     this.$Error(res.msg)
      //   }
      // })
    },
        // 定制 余额转到微呗start
    transferWeibeiClick() {
      this.showBalanceTurnWeibei = true
    },
    showBalanceTurnWeibeiClick(action, done) {
      if (action == 'confirm') {
        if (!this.balanceTurnBalanceMoneyWeibei) {
          this.$Error('金额不能为空')
          done(false)
          return false
        } else {
          this.$loadingWrap.show()
          const sendData = {
            money: this.balanceTurnBalanceMoneyWeibei,
            type: 3
          }
          weiBeiTransferAccount(sendData).then(res => {
            this.$loadingWrap.close()
            if (res.status == 1) {
              this.$Error('操作成功')
              this.balanceTurnBalanceMoneyWeibei = ''
              done()
              window.location.reload()
            } else {
              this.$Error(res.msg)
              done(false)
            }
          })
        }
      } else {
        this.balanceTurnBalanceMoneyWeibei = ''
        done()
      }
    }
    // 定制 余额转到微呗end
    // // 定制   梦泉  start
    // _getMQCloud() {
    //   getMQCloud().then(res => {
    //     this.$loadingWrap.close()
    //     if (res.status == 1) {
    //       this.dzData.cloud_pay_now_type = res.data.cloud_pay_now_type
    //       this.dzData.cloud_type = res.data.cloud_type
    //       this.dzData.cloud_default_1 = res.data.cloud_default_1
    //       this.dzData.cloud_default_2 = res.data.cloud_default_2
    //       this.dzData.cloud_default_3 = res.data.cloud_default_3
    //       this.dzData.cloud_agreement = res.data.cloud_agreement
    //       this.dzData.is_cloud_agreement = res.data.is_cloud_agreement
    //       this.dzData.agreement_name = res.data.agreement_name
    //     }
    //   })
    // }
    // // 定制   梦泉  end
  },
  beforeCreate() {
    // $('body').addClass('bg_white')
    document.querySelector('body').classList.add('bg_white')
  },
  destroyed() {
    // $('body').removeClass('bg_white')
    document.querySelector('body').classList.remove('bg_white')
  },
  beforeDestroy() {
    window.$$unsubscribe('txRefreshPage') // 取消关于此消息的所有订阅
  },
  created() {
    this.init()
    // const shop = this.$route.query.sid
    // const is_mq_cloud = this.$_shop('$_mq_cloud', shop)
    // this.dzData.is_mq_cloud = is_mq_cloud
    // if (is_mq_cloud) this._getMQCloud()
  },
  mounted() {
        // TODO 小程序触底加载更多
        window.addEventListener('reachbottom', () => {
          if (this.type === 1) {
            this.$refs.log1.onLoad()
          } else if (this.type === 2) {
            this.$refs.log2.onLoad()
          } else if (this.type === 3) {
            this.$refs.log3.onLoad()
          }
        })

        // window.addEventListener('wxshow', () => {
        //   this.showCashPop = false
        //   this.init()
        // })
        window.$$subscribe('txRefreshPage', data => {
          // console.log(data,'refresh')
          this.showCashPop = false
          this.init()
      })
  },
})
</script>

<style lang="scss">
@import '../../../../styles/mixin';
.balance-tx {
  overflow: hidden;
  .cashnote {
    .cashtext {
      width: 750px;
      line-height: 80px;
      box-sizing: border-box;
      padding: 0 30px;
      position: relative;
      display: flex;
      font-size: 26px;
      color: #f38847;
      background: rgba(255, 242, 216, 1);
      p {
        white-space: nowrap;
      }
      span {
        display: block;
        margin-left: 20px;
      }
    }
    .un-balance {
      margin: 20px 30px 0;
      font-size: 24px;
      color: #666666;
      @include lineClamp(24px, 1, 1);
      height: 24px;
    }
  }
  .balance-contanier {
    width: 700px;
    height: 328px;
    background: url("https://img.wifenxiao.com/h5-wfx/images/user/cash_bg.png") center top
      no-repeat #f4f4f4;
    background-size: 100%;
    margin: 25px auto;
    .tl_title {
        padding-top: 15px;
        color: #ffd9dd;
        font-size: 30px;
        text-align: center;
        position: relative;
        top: 15px;
      }
    .balance-content {
      padding-top: 48px;
      li {
        width: 50%;
        float: left;
        color: #ffd9dd;
        position: relative;
        p {
          font-size: 26px;
          font-weight: 500;
          text-align: center;
        }
        &:first-child {
          &::after {
            content: "";
            height: 80px;
            width: 0;
            border-right: 1px solid #ff7c86;
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
          }
        }
        strong {
          display: block;
          font-size: 50px;
          margin-bottom: 30px;
          font-weight: normal;
          letter-spacing: 3px;
          max-width: 99%;
          color: #fff;
          @include showEllipsis;
          i {
            display: inline-block;
            font-size: 28px;
            margin-right: 8px;
          }
        }
      }
    }
    .getcash-btn {
      display: inline-block;
      position: relative;
      width: 100%;
      height: 60px;
      border-radius: 4px;
      margin: 0 auto;
      text-align: center;
      .cash-apply {
        display: inline-block;
        width: 190px;
        height: 60px;
        line-height: 60px;
        border: 2px solid #fff;
        border-radius: 30px;
        background: transparent;
        font-size: 26px;
        font-weight: 500;
        color: #fff;
        text-align: center;
      }
    }
  }
  .balance-content-tl{
    display: flex;
    justify-content: center;
    align-items: center;
    li{
      &:first-child {
        &::after {
          content: "";
          height: 80px;
          width: 0;
          border-right: 1px solid transparent !important;
          position: absolute;
          right: 0;
          top: 50%;
          transform: translateY(-50%);
        }
      }
    }
  }

  .cash-detail {
    margin: 0 30px;
    .tab-nav {
      // border-bottom: 4px solid #f3f3f3;
      // border-width: 4px;
      display: flex;
      justify-content: space-between;
      span {
        position: relative;
        flex: 1;
        height: 106px;
        line-height: 106px;
        font-size: 32px;
        font-weight: normal;
        text-align: center;
        color: #333333;
        &.show {
          color: #f20b22;
          i {
            display: block;
            position: absolute;
            bottom: -2px;
            left: 50%;
            height: 5px;
            width: 56px;
            border-radius: 3px;
            transform: translateX(-50%);
            background: #f20b22;
          }
        }
      }
    }
  }
  .detail-item {
    margin: 20px 0 0;
    border: 0;
    background: #fff;
    border-radius: 20px;
  }
  // 提现类型弹层
  .withdrawalTypeBox_wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    .withdrawalTypeBox_block {
      position: relative;
      min-width: 600px;
      padding: 54px 70px;
      border-radius: 20px;
      background-color: #fff;
      .block_img{
        position: absolute;
        top: 30px;
        right: 30px;
        width: 28px;
        height: 28px;
        >img{
          max-width: 100%;
          width: 100%;
        }
      }
      h6{
        font-weight:bold;
        font-size:32px;
        color:#333;
        width: 100%;
        text-align: center;
        margin-bottom: 58px;
      }
      .block_selmain{
        display: flex;
        justify-content: space-around;
        margin-bottom: 60px;
        &_item{
          width:186px;
          height:186px;
          background-color:#F5F5F5;
          border: 1px solid #f5f5f5;
          border-radius:10px;
          margin-right: 54px;
          &:last-child{
            margin-right: 0;
          }
          i.icon{
            display: block;
            width: 65px;
            height: 65px;
            margin: 38px auto 18px;
            background-repeat: no-repeat;
            background-position: center;
            background-size: cover;
            &.personal{
              background-image: url("https://img.wifenxiao.com/h5-wfx/images/user/typeIcon.png");
            }
            &.enterprise{
              background-image: url("https://img.wifenxiao.com/h5-wfx/images/user/typeIcon1.png");
            }
          }
          .withdrawal_txt{
            display: flex;
            justify-content: center;
            align-items: center;
            >span{
              display: inline-block;
              font-size: 26px;
              color: #666;
              height: 26px;
            }
            .check{
              position: relative;
              width: 26px;
              height: 26px;
              margin-right: 10px;
              border: 1px solid #b3b3b3;
              border-radius: 50%;
            }
          }
          &.sel{
            border-color: #F10A1D;
            background-color:#FFF7F7;
            i.icon{
              &.personal{
                background-image: url("https://img.wifenxiao.com/h5-wfx/images/user/typeIcon_sel.png");
              }
              &.enterprise{
                background-image: url("https://img.wifenxiao.com/h5-wfx/images/user/typeIcon1_sel.png");
              }
            }
            .withdrawal_txt{
              >span{
                color: #EF0919;
              }
              .check{
                border-color: transparent;
                &::after{
                  content: '';
                  position: absolute;
                  right: 0;
                  bottom: 0;
                  display: block;
                  width: 26px;
                  height: 26px;
                  background: url("https://img.wifenxiao.com/h5-wfx/images/user/icon_check.png") no-repeat center/contain;
                }
              }
            }
          }
        }
      }
      .block_btn_next{
        font-size: 28px;
        color: #fff;
        width: 100%;
        height: 86px;
        line-height: 86px;
        text-align: center;
        background: linear-gradient(to right,#FE1B49, #E90104);
        border-radius: 42px;
      }
    }
  }
}
.donation-box{
  width: 600px;
  .title-box{
    padding-top: 48px;
    font-size:32px;
    font-weight: normal;
    line-height: 48px;
    text-align: center;
  }
  .con-box{
    position:relative;
    padding:40px 60px;
  }
  .input-box{
    margin:30px 0;
    font-size:28px;
    label{
      float:left;
      display:block;
      width:150px;
      line-height:64px;
      text-align:right;
      font-weight:normal;
      color: #333;
    }
    input{
      position:relative;
      float:left;
      -webkit-appearance: none;
      width:320px;
      height:64px;
      padding:16px 20px;
      font-size:26px;
      border:2px solid #EDEDED;
      border-radius:6px;
    }
    .info{
      display:inline-block;
      font-size:22px;
      color: #999999;
      padding:10px 0 0 150px;
    }
    &.friend-uid-box{
      position:relative;
      input{
        padding-right:100px;
      }
      .btn-verify{
        position:absolute;
        top:0;
        right:10px;
        width:100px;
        height:64px;
        font-size:26px;
        line-height:64px;
        text-align:center;
        color:#fff;
        background: #F30C23;
        border-radius: 2px;
      }
    }
    &.friend-info-box{
      .friend-info{
        display:flex;
        align-items:center;
        line-height:76px;
        .avatar{
          overflow:hidden;
          width:64px;
          height:64px;
          margin-right:10px;
          border-radius:50%;
          background:#ECECEC;
          img{
            display:block;
            width:100%;
          }
        }
        .nickname{
          flex:1;
          font-size:28px;
          font-weight:bold;
          @include showEllipsis;
        }
      }
    }
    &.amount-box{
      position:relative;
      input{
        padding-left:40px;
      }
      .mark{
        position:absolute;
        top:0;
        left:166px;
        line-height:64px;
      }
    }
  }
  .btn-box{
    display:flex;
    border-top:2px solid #ededed;
    .btn{
      width:50%;
      font-size:28px;
      line-height:94px;
      text-align:center;
      color:#333;
      &.confirm-btn{
        border-left:2px solid #ededed;
        color:#f20b22;
      }
    }
  }
  .donation-success-box{
    .img-box{
      width:104px;
      height:104px;
      margin:20px auto;
      img{
        display:block;
        width:100%;
      }
    }
    .txt{
      margin:20px 0 40px;
      font-size:36px;
      line-height: 50px;
      text-align:center;
    }
    .btn-box{
      .close-btn{
        width:100%;
      }
    }
  }
}
</style>
